//输入10个复数放在结构体数组，根据模的大小排序输出

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#define N 10

struct xx
{
	float r1;
	float r2;
	float m;
}s[N],*p;

void main()
{
	int i,j,k;
	struct xx temp;
	p = s;
	srand(time(NULL));
	for (i=0;i<N;i++)
	{
		(p+i)->r1 = rand()%100;
		(p+i)->r2 = rand()%100;
		(p+i)->m = sqrt(pow(((p+i)->r1),2)+pow(((p+i)->r2),2));
	}
	for (i=0;i<N;i++)
		printf("%6.2f %6.2f %6.2f \n",(p+i)->r1,(p+i)->r2,(p+i)->m);
	printf("==========================\n");
	for (i=0;i<N-1;i++)
	{
		k=i;
		for (j=i+1;j<N;j++)
		{
			if ((p+j)->m > (p+k)->m)
				k=j;
		}
		temp = *(p+i);
		*(p+i) = *(p+k);
		*(p+k) = temp;
	}

	for (i=0;i<N;i++)
                printf("%6.2f %6.2f %6.2f \n",(p+i)->r1,(p+i)->r2,(p+i)->m);
}




